abstract class $RO_BAG{E} < $CONTAINER{E}, $STR
****
A Bag contains objects in no specified order. A Bag can contain two equal objects.


Ancestors
$STR $CONTAINER{_} $ELT{_} $ELT

Descendants
$BAG{_} BAG{_} H_BAG{_}



Public


Features
count(e:E): INT;
**** Returns the number of occurences of 'e' in the bag.
equals(b: $RO_BAG{E}): BOOL;
**** Return true if self and "b" have the same elements in the same quantities
intersection(b: $RO_BAG{E}):$BAG{E};
**** result.count(e) = minimum_of(self.count(e),b.count(e))
is_subset(b: $RO_BAG{E}): BOOL;
n_unique: INT;
**** Returns the numver of different(!) elements in the bag.
union(b: $RO_BAG{E}): $BAG{E};
**** The union contains the elements of "self" and "b". result.count(e) = self.count(e) + b.count(e) Is this a good definition? Is not symmetric with intersection STL uses maximum rather than arithmetic sum
unique!: E;
**** Yields all element from the bag, but every element will be yielded not more than once.

The Sather Home Page